home *** CD-ROM | disk | FTP | other *** search
/ Champak 62 / Volume 62 - JOGO DISK .iso / Games / penguin_dinner.swf / scripts / __Packages / classes / game / CharActionQueue.as next >
Text File  |  2008-03-17  |  1KB  |  40 lines

  1. class classes.game.CharActionQueue
  2. {
  3.    function CharActionQueue()
  4.    {
  5.    }
  6.    function setTargetTile($initTile, $targetTile, $speed)
  7.    {
  8.       var _loc8_ = new classes.math.AStarPathfinder();
  9.       var _loc3_ = _loc8_.getOptimizedPath($initTile,$targetTile);
  10.       _loc3_.reverse();
  11.       var _loc4_ = [];
  12.       var _loc5_ = [];
  13.       var _loc6_ = _loc3_.length;
  14.       var _loc2_ = 0;
  15.       while(_loc2_ < _loc6_)
  16.       {
  17.          _loc4_.push((_loc3_[_loc2_].x + classes.math.Tile.DX) * classes.math.Tile.SIZE + 10);
  18.          _loc5_.push((_loc3_[_loc2_].y + classes.math.Tile.DY) * classes.math.Tile.SIZE + 10);
  19.          _loc2_ = _loc2_ + 1;
  20.       }
  21.       var _loc7_ = new classes.math.CatmullRomSpline(_loc4_,_loc5_);
  22.       this.pathQueue = _loc7_.getAllPoints($speed);
  23.    }
  24.    function getCoords()
  25.    {
  26.       var _loc2_ = this.pathQueue.shift();
  27.       if(this.pathQueue.length > 0)
  28.       {
  29.          _loc2_.end = false;
  30.          _loc2_.dx = this.pathQueue[0].x - _loc2_.x;
  31.          _loc2_.dy = this.pathQueue[0].y - _loc2_.y;
  32.       }
  33.       else
  34.       {
  35.          _loc2_.end = true;
  36.       }
  37.       return _loc2_;
  38.    }
  39. }
  40.